home *** CD-ROM | disk | FTP | other *** search
/ Multimedia Toolkit / Multimedia Toolkit.iso / pascal / devdac.pas < prev    next >
Pascal/Delphi Source File  |  1992-12-04  |  6KB  |  216 lines

  1. {****************************************************************************}
  2. {                                                                            }
  3. { MODULE:         DevDac                                                     }
  4. {                                                                            }
  5. { DESCRIPTION:    Device driver for all DAC-type sound cards. This includes  }
  6. {                 Uses timer polling.                                        }
  7. {                                                                            }
  8. { AUTHOR:         Juan Carlos Arévalo                                        }
  9. {                                                                            }
  10. { MODIFICATIONS:  Nobody (yet ;-)                                            }
  11. {                                                                            }
  12. { HISTORY:        12-Nov-1992 Documentation.                                 }
  13. {                                                                            }
  14. { (C) 1992 VangeliSTeam                                                      }
  15. {____________________________________________________________________________}
  16.  
  17. UNIT DevDAC;
  18.  
  19. INTERFACE
  20.  
  21. CONST                           { Device ID Strings. }
  22.   DACDevID      = 'DAC-Mono';
  23.   DAC2DevID     = 'DAC-Stereo';
  24.   MixDAC2DevID  = 'Mix-DAC-Stereo';
  25.   Mix2DAC2DevID = 'Mix2-DAC-Stereo';
  26.  
  27.  
  28. { Configuration. }
  29.  
  30. CONST
  31.   DacPort  : WORD = $378;
  32.   LDacPort : WORD = $378;
  33.   RDacPort : WORD = $378;
  34.  
  35. IMPLEMENTATION
  36.  
  37. USES SoundDevices, StrConst;
  38.  
  39.  
  40.  
  41.  
  42. {$L DEVDAC}    { Assembler IRQs. }
  43.  
  44. PROCEDURE DACIntHandler;      FAR; EXTERNAL;
  45. PROCEDURE DAC2IntHandler;     FAR; EXTERNAL;
  46. PROCEDURE MixDAC2IntHandler;  FAR; EXTERNAL;
  47. PROCEDURE Mix2DAC2IntHandler; FAR; EXTERNAL;
  48.  
  49.  
  50.  
  51.  
  52. {----------------------------------------------------------------------------}
  53. { Name functions.                                                            }
  54. {____________________________________________________________________________}
  55.  
  56. FUNCTION DACName : TDevName; FAR;
  57.   BEGIN
  58.     DACName := GetString(StrDevDACName);
  59.   END;
  60.  
  61. FUNCTION DAC2Name : TDevName; FAR;
  62.   BEGIN
  63.     DAC2Name := GetString(StrDevDAC2Name);
  64.   END;
  65.  
  66. FUNCTION MixDAC2Name : TDevName; FAR;
  67.   BEGIN
  68.     MixDAC2Name := GetString(StrDevMixDAC2Name);
  69.   END;
  70.  
  71. FUNCTION Mix2DAC2Name : TDevName; FAR;
  72.   BEGIN
  73.     Mix2DAC2Name := GetString(StrDevMix2DAC2Name);
  74.   END;
  75.  
  76.  
  77.  
  78.  
  79. {----------------------------------------------------------------------------}
  80. { Autodetect routine. It's always present (can't be detected).               }
  81. {____________________________________________________________________________}
  82.  
  83. FUNCTION DACDetect : BOOLEAN; FAR;
  84.   BEGIN
  85.     DACDetect := TRUE;
  86.   END;
  87.  
  88.  
  89.  
  90.  
  91. {----------------------------------------------------------------------------}
  92. { Device Initialisation routine.                                             }
  93. {____________________________________________________________________________}
  94.  
  95. PROCEDURE Init(Hz: WORD); FAR; 
  96.   BEGIN
  97.     CalcTimerData(Hz);    { Standard polling initialisation. }
  98.     InitTimer;
  99.   END;
  100.  
  101.  
  102.  
  103.  
  104. {----------------------------------------------------------------------------}
  105. { Device deinitialisation routine.                                           }
  106. {____________________________________________________________________________}
  107.  
  108. PROCEDURE DevEnd; FAR; ASSEMBLER;
  109.   ASM
  110.   END;
  111.  
  112.  
  113.  
  114.  
  115. {----------------------------------------------------------------------------}
  116. { Accesory routines.                                                         }
  117. {____________________________________________________________________________}
  118.  
  119. PROCEDURE DevChgHz(Hz: WORD); FAR;
  120.   BEGIN
  121.     CalcTimerData(Hz);
  122.     InitTimer;
  123.   END;
  124.  
  125. PROCEDURE DevPoll; FAR;
  126.   BEGIN
  127.   END;
  128.  
  129.  
  130.  
  131.  
  132. {----------------------------------------------------------------------------}
  133. { Device records.                                                            }
  134. {____________________________________________________________________________}
  135.  
  136. CONST
  137.   DACData : TSoundDevice = (
  138.     DevID      : DACDevID;
  139.     DMA        : FALSE
  140.   );
  141.  
  142.   DAC2Data : TSoundDevice = (
  143.     DevID      : DAC2DevID;
  144.     DMA        : FALSE
  145.   );
  146.  
  147.   MixDAC2Data : TSoundDevice = (
  148.     DevID      : MixDAC2DevID;
  149.     DMA        : FALSE
  150.   );
  151.  
  152.   Mix2DAC2Data : TSoundDevice = (
  153.     DevID      : Mix2DAC2DevID;
  154.     DMA        : FALSE
  155.   );
  156.  
  157.  
  158.  
  159.  
  160. {----------------------------------------------------------------------------}
  161. { Init code.                                                                 }
  162. {____________________________________________________________________________}
  163.  
  164. BEGIN
  165.  
  166.   WITH DACData DO BEGIN
  167.     Name            := DACName;
  168.     AutoDetect      := DACDetect;
  169.     InitRut         := Init;
  170.     ChgHzProc       := DevChgHz;
  171.     GetRealFreqProc := GetRealFreq;
  172.     TimerHandler    := DACIntHandler;
  173.     PollRut         := DevPoll;
  174.     EndRut          := DevEnd;
  175.   END;
  176.  
  177.   WITH DAC2Data DO BEGIN
  178.     Name            := DAC2Name;
  179.     AutoDetect      := DACDetect;
  180.     InitRut         := Init;
  181.     ChgHzProc       := DevChgHz;
  182.     GetRealFreqProc := GetRealFreq;
  183.     TimerHandler    := DAC2IntHandler;
  184.     PollRut         := DevPoll;
  185.     EndRut          := DevEnd;
  186.   END;
  187.  
  188.   WITH MixDAC2Data DO BEGIN
  189.     Name            := MixDAC2Name;
  190.     AutoDetect      := DACDetect;
  191.     InitRut         := Init;
  192.     ChgHzProc       := DevChgHz;
  193.     GetRealFreqProc := GetRealFreq;
  194.     TimerHandler    := MixDAC2IntHandler;
  195.     PollRut         := DevPoll;
  196.     EndRut          := DevEnd;
  197.   END;
  198.  
  199.   WITH Mix2DAC2Data DO BEGIN
  200.     Name            := Mix2DAC2Name;
  201.     AutoDetect      := DACDetect;
  202.     InitRut         := Init;
  203.     ChgHzProc       := DevChgHz;
  204.     GetRealFreqProc := GetRealFreq;
  205.     TimerHandler    := Mix2DAC2IntHandler;
  206.     PollRut         := DevPoll;
  207.     EndRut          := DevEnd;
  208.   END;
  209.  
  210.   InitDevice(@Mix2DAC2Data);
  211.   InitDevice(@MixDAC2Data);
  212.   InitDevice(@DAC2Data);
  213.   InitDevice(@DACData);
  214.  
  215. END.
  216.